package com.bins.dentist.clinic.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.bins.dentist.clinic.model.dto.AppointmentDto;
import com.bins.dentist.clinic.model.dto.PatientPageDto;
import com.bins.dentist.clinic.model.vo.AppointmentVo;
import com.bins.dentist.clinic.model.vo.ResultVo;
import com.bins.dentist.clinic.model.vo.SimpleSelectVo;
import com.bins.dentist.clinic.service.AppointmentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 预约表 前端控制器
 * </p>
 *
 * @author bins
 * @since 2023-04-23 13:22:36
 */
@RestController
@RequestMapping("/appointment")
public class AppointmentController {

    @Autowired
    private AppointmentService appointmentService;

    @GetMapping("/page")
    public ResultVo<IPage<AppointmentVo>> pageList(PatientPageDto pageDto) {
        return ResultVo.ok().data(appointmentService.getPage(pageDto));
    }

    @GetMapping("/detail")
    public ResultVo<AppointmentVo> detail(AppointmentDto dto) {
        return ResultVo.ok().data(appointmentService.getDetail(dto));
    }

    @PostMapping("/save")
    public ResultVo<AppointmentVo> savePatient(@RequestBody AppointmentDto dto) {
        return ResultVo.ok().data(appointmentService.saveItem(dto));
    }

    @PostMapping("/delete")
    public ResultVo<Integer> deleteItem(@RequestBody AppointmentDto dto){
        return ResultVo.ok().data(appointmentService.deleteItem(dto));
    }

    @GetMapping("/select")
    public ResultVo<List<SimpleSelectVo>> selectList(AppointmentDto dto) {
        return ResultVo.ok().data(appointmentService.selectList(dto));
    }
}

